package com.zl.cms.model;

import org.hibernate.validator.constraints.Email;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.util.Date;

/**
 * User: zl email:c3tc3tc3t@126.com Date: 14-1-13 Time: 下午3:50
 */
// @Entity
// @Table(name="t_user")
public class User {
  private int id;
  /**
   * 用户登录名称
   */
  private String username;
  /**
   * 用户登录密码
   */
  private String password;
  /**
   * 用户中文名称
   */
  private String nickname;
  /**
   * 用户邮件
   */
  private String email;
  /**
   * 用户联系电话
   */
  private String phone;
  /**
   * 用户状态，0停用，1启用
   */
  private int status;

  /**
   * 用户创建时间
   */
  private Date createdate;

  public User() {}

  public User(String username, String password, String nickname, String email, String phone,
      int status) {
    this.username = username;
    this.password = password;
    this.nickname = nickname;
    this.email = email;
    this.phone = phone;
    this.status = status;
  }

  public User(int id, String username, String password, String nickname, String email,
      String phone, int status) {
    this.id = id;
    this.username = username;
    this.password = password;
    this.nickname = nickname;
    this.email = email;
    this.phone = phone;
    this.status = status;
  }

  @Override
  public boolean equals(Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;

    User user = (User) o;

    if (id != user.getId()) return false;
    if (!email.equals(user.getEmail())) return false;
    if (!username.equals(user.getUsername())) return false;

    return true;
  }

  @Override
  public int hashCode() {
    int result = id;
    result = 31 * result + username.hashCode();
    return result;
  }

  @Override
  public String toString() {
    return "User{" + "id=" + id + ", username='" + username + '\'' + ", password='" + password
        + '\'' + ", nickname='" + nickname + '\'' + ", email='" + email + '\'' + ", phone='"
        + phone + '\'' + ", status=" + status + '}';
  }

  // @Id
  // @GeneratedValue(strategy = GenerationType.IDENTITY)
  public int getId() {
    return id;
  }

  public void setId(int id) {
    this.id = id;
  }

  public String getUsername() {
    return username;
  }

  public void setUsername(String username) {
    this.username = username;
  }

  public String getPassword() {
    return password;
  }

  public void setPassword(String password) {
    this.password = password;
  }

  public String getNickname() {
    return nickname;
  }

  public void setNickname(String nickname) {
    this.nickname = nickname;
  }

  public String getEmail() {
    return email;
  }

  public void setEmail(String email) {
    this.email = email;
  }

  public String getPhone() {
    return phone;
  }

  public void setPhone(String phone) {
    this.phone = phone;
  }

  public int getStatus() {
    return status;
  }

  public void setStatus(int status) {
    this.status = status;
  }

  // @Column(name="create_date")
  public Date getCreatedate() {
    return createdate;
  }

  public void setCreatedate(Date createdate) {
    this.createdate = createdate;
  }
}
